//
//  BQMineSetController.m
//  BeeQuick
//
//  Created by student on 2017/7/10.
//  Copyright © 2017年 BecomeRich. All rights reserved.
//

#import "BQMineSetController.h"
#import "BQAuthorController.h"
#import <Masonry.h>

@interface BQMineSetController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation BQMineSetController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addTableView];
    
   
}

- (void)viewWillAppear:(BOOL)animated{
    self.title = @"设置";
    self.navigationController.navigationBar.hidden = NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:  UIBarMetricsDefault];
    self.navigationController.navigationBar.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
}

#pragma __addTableView__

- (void)addTableView{
    
    UITableView *tableView = [[UITableView alloc]init];
    tableView.delegate = self;
    tableView.dataSource = self;
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"BQMineSetControllerCell"];
    [self.view addSubview:tableView];
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(20);
        make.bottom.trailing.leading.equalTo(self.view);
    }];
    tableView.tableFooterView = [UIView new];
}

#pragma __UITableViewDataSource__

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section == 1) {
        return 1;
    }
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BQMineSetControllerCell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor groupTableViewBackgroundColor];
    if (indexPath.section == 0) {
        cell.textLabel.text = indexPath.row == 0 ? @" 关于小熊": @" 清除缓存";
        if (indexPath.row == 0) {
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }else{
            UILabel *label = [[UILabel alloc]init];
            label.text = @"0.88M";
            label.font= [UIFont systemFontOfSize:14];
            label.textColor = [UIColor grayColor];
            [cell.contentView addSubview:label];
            [label mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.top.equalTo(cell.contentView);
                make.trailing.equalTo(cell.contentView).offset(-8);
            }];
        }
    }
    if (indexPath.section == 1) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"退出当前账号";
        label.font= [UIFont systemFontOfSize:14];
        [cell.contentView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(cell.contentView);
        }];

    }
    cell.textLabel.font = [UIFont systemFontOfSize:14];
       return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 0;
    }
    return 18;
}
#pragma __UITableViewDelegate__

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            BQAuthorController *authorVC = [[BQAuthorController alloc]init];
            [self.navigationController pushViewController:authorVC animated:NO];
            
        }else{
            NSLog(@"你点击了清除缓存");
        }
        
    }
    if (indexPath.section == 1) {
        NSLog(@"你点击了退出当前账号");
    }
}

@end
